﻿using UnityEngine;
using System.Collections;

public class TankMovement : MonoBehaviour {

	public float speed = 5;
	public float angularSpeed = 20;
	public float number = 1;//1,2 通过编号区分不通控制

	private Rigidbody rigidbody;
	// Use this for initialization
	void Start () {
		rigidbody = this.GetComponent<Rigidbody> ();
	}
	
	// Update is called once per frame
	void Update () {
		
	}
	void FixedUpdate(){
		//前后移动
		float v = Input.GetAxis ("VerticalPlayer"+number);
		rigidbody.velocity = transform.forward * v * speed;

		//水平旋转
		float h = Input.GetAxis ("HorizontalPlayer"+number);
		rigidbody.angularVelocity = transform.up * h * angularSpeed;
	}
}
